<%@ page contentType="text/html;charset=UTF-8" %>

<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录界面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="app" class="container">
    <div class="row">
        <div class="col-md-4"></div>

            <div class="col-md-4">
                <p class="h1 text-center">缴费修改</p>
                <div>
                    <input type="text"  name="stuId" class="form-control" v-model="result[0].stuId">
                </div>
                <br>
                <div>
                    <input type="text" name="term" class="form-control" v-model="result[0].term">
                </div>
                <br>
                <div>
                    <input type="text" name="clazz" class="form-control" v-model="result[0].clazz">
                </div>
                <br>
                <div>
                    <input type="text" name="name" class="form-control" v-model="result[0].name">
                </div>
                <br>
                <div>
                    <input type="text" name="payment" class="form-control" v-model="result[0].payment">
                </div>
                <br>
                <div>
                    <input type="text" name="arrearage" class="form-control" v-model="result[0].arrearage">
                </div>
                <br>
                <button type="button" @click="edit()" class="btn btn-info btn-block" >提交</button>
            </div>

        <div class="col-md-4">
        </div>
    </div>
</div>

<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            stuId:0,
            result:[],

        },
        methods:
            {
                getOne:function(){
                    $.ajax({
                        url: "/demo/Pay/getOne",
                        type: 'post',
                        data:{"stuId":this.stuId},
                        success:function (result) {
                            console.log("result---" + result)
                            app.result = result;
                            console.log("app.result--" + app.result)
                        }
                    })
                },
                edit: function () {
                    $.ajax({
                        url: "/demo/Pay/edit",
                        type: 'post',
                        data: JSON.stringify(this.result[0]),
                        contentType:'application/json',
                        dataType:'json',
                        success: function (result) {
                            if (result == "成功") {
                                window.location.href = "/demo/Pay/gotoget"
                            } else
                                alert("修改失败！请重新输入！");
                        },
                        error:function (result) {
                            alert("请求失败!学号不可修改！")
                        }
                    })
                }
            }
    })
    $(function () {
        console.log('${stuId}');
        app.stuId = '${stuId}';
        console.log(app.stuId);
        app.getOne();
    })
</script>

</body>
</html>